package com.buy;

import com.buy.service.BuyingProblem;
import com.buy.service.Impl.BuyingProblemFour;
import com.buy.service.Impl.BuyingProblemOne;
import com.buy.service.Impl.BuyingProblemThree;
import com.buy.service.Impl.BuyingProblemTwo;

import java.util.Scanner;

public class Apply {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        run(scanner);
    }

    public static  void  run(Scanner scanner){
        System.out.println("请输入选择问题(1，2，3，4),5为退出程序：");
        Integer quantity = scanner.nextInt(); // 读取用户输入的一行文本
        BuyingProblem buyingProblem = null;
        if(quantity==1){
            buyingProblem = new BuyingProblemOne();
        }else if (quantity==2){
            buyingProblem = new BuyingProblemTwo();
        }else if (quantity==3){
            buyingProblem = new BuyingProblemThree();
        }else if (quantity==4){
            buyingProblem = new BuyingProblemFour();
        }else if(quantity==5){
            return;
        }
        if(buyingProblem == null){
            System.out.println("请选择范围内的数字");
        }
        buyingProblem.problem();
        run(scanner);
    }

}
